/**
 * Created by developer on 17-3-3.
 */
var $shady = $(".masking");
var $dropDown = $("#show_info");
var $id;
var $status;
var $form = $(".container-modify-complaints");

$(function () {
    $(".list .list-item").on("click", function () {
        $(".list .list-item").each(function (i, item) {
            $(item).css("margin-bottom","0px");
        });
        var currentId = $(this).attr("id");
        if ($dropDown.css("display") == "none" && getId(currentId) == "open") {
            $dropDown.show(10);
            $dropDown.css({
                top:$(this).position().top + 44 +"px",
                left:$(this).position().left
            });
            $(this).css("margin-bottom", "300px");
        } else if(getId(currentId) == "close") {
            $dropDown.hide(10);
            $(this).css("margin-bottom", "0px");
        }
    });
    
    $("#modify_complaints").click(function () {
        modifyDisplayFlex($form);
    });

    $form.find(".cancel").on("click", function () {
        modifyDisplayNone($form);
    });
});

//修改css样式display为flex
function modifyDisplayFlex(obj) {
    obj.css("display", "flex");
    $shady.css("display", "block");
}
//修改css样式display为none
function modifyDisplayNone(obj) {
    obj.css("display", "none");
    $shady.css("display", "none");
}

function getId(currentId) {
    if ($id == currentId) {
        $status = "close";
        $id = "";
    } else {
        $status = "open";
        $id = currentId;
    }
    return $status;
}

